package com.caregiver.watch.business.care.enums;

import lombok.Getter;

/**
 * 订单状态枚举
 */
@Getter
public enum OrderStatusEnum {
    
    /**
     * 禁用
     */
    DISABLED(-1, "禁用"),
    
    /**
     * 已取消
     */
    CANCELLED(0, "已取消"),
    
    /**
     * 待支付
     */
    PENDING_PAYMENT(1, "待支付"),
    
    /**
     * 支付成功
     */
    PAYMENT_SUCCESS(2, "支付成功"),
    
    /**
     * 支付失败
     */
    PAYMENT_FAILED(3, "支付失败"),
    
    /**
     * 未生效
     */
    NOT_EFFECTIVE(4, "未生效");

    private final Integer code;
    private final String description;

    OrderStatusEnum(Integer code, String description) {
        this.code = code;
        this.description = description;
    }

    /**
     * 根据code获取枚举
     * @param code 状态码
     * @return 对应的枚举值，未找到则返回null
     */
    public static OrderStatusEnum parse(Integer code) {
        for (OrderStatusEnum status : values()) {
            if (status.code.equals(code)) {
                return status;
            }
        }
        return null;
    }
}
